﻿@using Blazorise.Modules
@typeparam TItem
@inherits _DataGridCellEdit<TItem>
@if ( ValueType == typeof( string ) )
{
    <TextEdit ElementId="@elementId" Text="@CellEditContext.CellValue?.ToString()" TextChanged="@OnEditValueChanged" TextExpression="@stringExpression" ReadOnly="@Column.Readonly" Pattern="@ValidationPattern">
        <Feedback>
            @if ( ShowValidationFeedback )
            {
                <ValidationError />
            }
        </Feedback>
    </TextEdit>
}
else if ( ValueType == typeof( decimal ) )
{
    <NumericPicker ElementId="@elementId" TValue="decimal" Value="@((decimal)CellEditContext.CellValue)" ValueChanged="@OnEditValueChanged" ValueExpression="@decimalExpression" ReadOnly="@Readonly" Pattern="@ValidationPattern" Step="@Step" Decimals="@Decimals" DecimalSeparator="@DecimalSeparator" Culture="@Culture" ShowStepButtons="@ShowStepButtons" EnableStep="@EnableStep">
        <Feedback>
            @if ( ShowValidationFeedback )
            {
                <ValidationError />
            }
        </Feedback>
    </NumericPicker>
}
else if ( ValueType == typeof( decimal? ) )
{
    <NumericPicker ElementId="@elementId" TValue="decimal?" Value="@((decimal?)CellEditContext.CellValue)" ValueChanged="@OnEditValueChanged" ValueExpression="@nullableDecimalExpression" ReadOnly="@Readonly" Pattern="@ValidationPattern" Step="@Step" Decimals="@Decimals" DecimalSeparator="@DecimalSeparator" Culture="@Culture" ShowStepButtons="@ShowStepButtons" EnableStep="@EnableStep">
        <Feedback>
            @if ( ShowValidationFeedback )
            {
                <ValidationError />
            }
        </Feedback>
    </NumericPicker>
}
else if ( ValueType == typeof( double ) )
{
    <NumericPicker ElementId="@elementId" TValue="double" Value="@((double)CellEditContext.CellValue)" ValueChanged="@OnEditValueChanged" ValueExpression="@doubleExpression" ReadOnly="@Readonly" Pattern="@ValidationPattern" Step="@Step" Decimals="@Decimals" DecimalSeparator="@DecimalSeparator" Culture="@Culture" ShowStepButtons="@ShowStepButtons" EnableStep="@EnableStep">
        <Feedback>
            @if ( ShowValidationFeedback )
            {
                <ValidationError />
            }
        </Feedback>
    </NumericPicker>
}
else if ( ValueType == typeof( double? ) )
{
    <NumericPicker ElementId="@elementId" TValue="double?" Value="@(( double?)CellEditContext.CellValue)" ValueChanged="@OnEditValueChanged" ValueExpression="@nullableDoubleExpression" ReadOnly="@Readonly" Pattern="@ValidationPattern" Step="@Step" Decimals="@Decimals" DecimalSeparator="@DecimalSeparator" Culture="@Culture" ShowStepButtons="@ShowStepButtons" EnableStep="@EnableStep">
        <Feedback>
            @if ( ShowValidationFeedback )
            {
                <ValidationError />
            }
        </Feedback>
    </NumericPicker>
}
else if ( ValueType == typeof( float ) )
{
    <NumericPicker ElementId="@elementId" TValue="float" Value="@((float)CellEditContext.CellValue)" ValueChanged="@OnEditValueChanged" ValueExpression="@floatExpression" ReadOnly="@Readonly" Pattern="@ValidationPattern" Step="@Step" Decimals="@Decimals" DecimalSeparator="@DecimalSeparator" Culture="@Culture" ShowStepButtons="@ShowStepButtons" EnableStep="@EnableStep">
        <Feedback>
            @if ( ShowValidationFeedback )
            {
                <ValidationError />
            }
        </Feedback>
    </NumericPicker>
}
else if ( ValueType == typeof( float? ) )
{
    <NumericPicker ElementId="@elementId" TValue="float?" Value="@((float?)CellEditContext.CellValue)" ValueChanged="@OnEditValueChanged" ValueExpression="@nullableFloatExpression" ReadOnly="@Readonly" Pattern="@ValidationPattern" Step="@Step" Decimals="@Decimals" DecimalSeparator="@DecimalSeparator" Culture="@Culture" ShowStepButtons="@ShowStepButtons" EnableStep="@EnableStep">
        <Feedback>
            @if ( ShowValidationFeedback )
            {
                <ValidationError />
            }
        </Feedback>
    </NumericPicker>
}
else if ( ValueType == typeof( int ) )
{
    <NumericPicker ElementId="@elementId" TValue="int" Value="@((int)CellEditContext.CellValue)" ValueChanged="@OnEditValueChanged" ValueExpression="@intExpression" ReadOnly="@Readonly" Pattern="@ValidationPattern" Step="@Step" Decimals="@Decimals" DecimalSeparator="@DecimalSeparator" Culture="@Culture" ShowStepButtons="@ShowStepButtons" EnableStep="@EnableStep">
        <Feedback>
            @if ( ShowValidationFeedback )
            {
                <ValidationError />
            }
        </Feedback>
    </NumericPicker>
}
else if ( ValueType == typeof( int? ) )
{
    <NumericPicker ElementId="@elementId" TValue="int?" Value="@((int?)CellEditContext.CellValue)" ValueChanged="@OnEditValueChanged" ValueExpression="@nullableIntExpression" ReadOnly="@Readonly" Pattern="@ValidationPattern" Step="@Step" Decimals="@Decimals" DecimalSeparator="@DecimalSeparator" Culture="@Culture" ShowStepButtons="@ShowStepButtons" EnableStep="@EnableStep">
        <Feedback>
            @if ( ShowValidationFeedback )
            {
                <ValidationError />
            }
        </Feedback>
    </NumericPicker>
}
else if ( ValueType == typeof( long ) )
{
    <NumericPicker ElementId="@elementId" TValue="long" Value="@((long)CellEditContext.CellValue)" ValueChanged="@OnEditValueChanged" ValueExpression="@longExpression" ReadOnly="@Readonly" Pattern="@ValidationPattern" Step="@Step" Decimals="@Decimals" DecimalSeparator="@DecimalSeparator" Culture="@Culture" ShowStepButtons="@ShowStepButtons" EnableStep="@EnableStep">
        <Feedback>
            @if ( ShowValidationFeedback )
            {
                <ValidationError />
            }
        </Feedback>
    </NumericPicker>
}
else if ( ValueType == typeof( long? ) )
{
    <NumericPicker ElementId="@elementId" TValue="long?" Value="@((long?)CellEditContext.CellValue)" ValueChanged="@OnEditValueChanged" ValueExpression="@nullableLongExpression" ReadOnly="@Readonly" Pattern="@ValidationPattern" Step="@Step" Decimals="@Decimals" DecimalSeparator="@DecimalSeparator" Culture="@Culture" ShowStepButtons="@ShowStepButtons" EnableStep="@EnableStep">
        <Feedback>
            @if ( ShowValidationFeedback )
            {
                <ValidationError />
            }
        </Feedback>
    </NumericPicker>
}
else if ( ValueType == typeof( bool ) )
{
    <Check ElementId="@elementId" TValue="bool" Checked="@((bool)CellEditContext.CellValue)" CheckedChanged="@OnEditValueChanged" CheckedExpression="@boolExpression" ReadOnly="@Readonly">
        <Feedback>
            @if ( ShowValidationFeedback )
            {
                <ValidationError />
            }
        </Feedback>
    </Check>
}
else if ( ValueType == typeof( bool? ) )
{
    <Check ElementId="@elementId" TValue="bool?" Checked="@((bool?)CellEditContext.CellValue)" CheckedChanged="@OnEditValueChanged" CheckedExpression="@nullableBoolExpression" ReadOnly="@Readonly">
        <Feedback>
            @if ( ShowValidationFeedback )
            {
                <ValidationError />
            }
        </Feedback>
    </Check>
}
else if ( ValueType == typeof( DateTime ) )
{
    <DateEdit ElementId="@elementId" TValue="DateTime" Date="@((DateTime)CellEditContext.CellValue)" DateChanged="@OnEditValueChanged" DateExpression="@dateTimeExpression" ReadOnly="@Readonly" Pattern="@ValidationPattern" InputMode="@DateInputMode">
        <Feedback>
            @if ( ShowValidationFeedback )
            {
                <ValidationError />
            }
        </Feedback>
    </DateEdit>
}
else if ( ValueType == typeof( DateTime? ) )
{
    <DateEdit ElementId="@elementId" TValue="DateTime?" Date="@((DateTime?)CellEditContext.CellValue)" DateChanged="@OnEditValueChanged" DateExpression="@nullableDateTimeExpression" ReadOnly="@Readonly" Pattern="@ValidationPattern" InputMode="@DateInputMode">
        <Feedback>
            @if ( ShowValidationFeedback )
            {
                <ValidationError />
            }
        </Feedback>
    </DateEdit>
}
else if ( ValueType == typeof( DateOnly ) )
{
    <DateEdit ElementId="@elementId" TValue="DateOnly" Date="@((DateOnly)CellEditContext.CellValue)" DateChanged="@OnEditValueChanged" DateExpression="@dateOnlyExpression" ReadOnly="@Readonly" Pattern="@ValidationPattern" InputMode="@DateInputMode">
        <Feedback>
            @if ( ShowValidationFeedback )
            {
                <ValidationError />
            }
        </Feedback>
    </DateEdit>
}
else if ( ValueType == typeof( DateOnly? ) )
{
    <DateEdit ElementId="@elementId" TValue="DateOnly?" Date="@((DateOnly?)CellEditContext.CellValue)" DateChanged="@OnEditValueChanged" DateExpression="@nullableDateOnlyExpression" ReadOnly="@Readonly" Pattern="@ValidationPattern" InputMode="@DateInputMode">
        <Feedback>
            @if ( ShowValidationFeedback )
            {
                <ValidationError />
            }
        </Feedback>
    </DateEdit>
}
else if ( ValueType == typeof( DateTimeOffset ) )
{
    <DateEdit ElementId="@elementId" TValue="DateTimeOffset" Date="@((DateTimeOffset)CellEditContext.CellValue)" DateChanged="@OnEditValueChanged" DateExpression="@dateTimeOffsetExpression" ReadOnly="@Readonly" Pattern="@ValidationPattern" InputMode="@DateInputMode">
        <Feedback>
            @if ( ShowValidationFeedback )
            {
                <ValidationError />
            }
        </Feedback>
    </DateEdit>
}
else if ( ValueType == typeof( DateTimeOffset? ) )
{
    <DateEdit ElementId="@elementId" TValue="DateTimeOffset?" Date="@((DateTimeOffset?)CellEditContext.CellValue)" DateChanged="@OnEditValueChanged" DateExpression="@nullableDateTimeOffsetExpression" ReadOnly="@Readonly" Pattern="@ValidationPattern" InputMode="@DateInputMode">
        <Feedback>
            @if ( ShowValidationFeedback )
            {
                <ValidationError />
            }
        </Feedback>
    </DateEdit>
}
else if ( ValueType == typeof( TimeSpan ) )
{
    <TimeEdit ElementId="@elementId" TValue="TimeSpan" Time="@((TimeSpan)CellEditContext.CellValue)" TimeChanged="@OnEditValueChanged" TimeExpression="@timeSpanExpression" ReadOnly="@Readonly">
        <Feedback>
            @if ( ShowValidationFeedback )
            {
                <ValidationError />
            }
        </Feedback>
    </TimeEdit>
}
else if ( ValueType == typeof( TimeSpan? ) )
{
    <TimeEdit ElementId="@elementId" TValue="TimeSpan?" Time="@((TimeSpan?)CellEditContext.CellValue)" TimeChanged="@OnEditValueChanged" TimeExpression="@nullableTimeSpanExpression" ReadOnly="@Readonly">
        <Feedback>
            @if ( ShowValidationFeedback )
            {
                <ValidationError />
            }
        </Feedback>
    </TimeEdit>
}
else if ( ValueType == typeof( TimeOnly ) )
{
    <TimeEdit ElementId="@elementId" TValue="TimeOnly" Time="@((TimeOnly)CellEditContext.CellValue)" TimeChanged="@OnEditValueChanged" TimeExpression="@timeOnlyExpression" ReadOnly="@Readonly">
        <Feedback>
            @if ( ShowValidationFeedback )
            {
                <ValidationError />
            }
        </Feedback>
    </TimeEdit>
}
else if ( ValueType == typeof( TimeOnly? ) )
{
    <TimeEdit ElementId="@elementId" TValue="TimeOnly?" Time="@((TimeOnly?)CellEditContext.CellValue)" TimeChanged="@OnEditValueChanged" TimeExpression="@nullableTimeOnlyExpression" ReadOnly="@Readonly">
        <Feedback>
            @if ( ShowValidationFeedback )
            {
                <ValidationError />
            }
        </Feedback>
    </TimeEdit>
}
else
{
    <TextEdit ElementId="@elementId" Text="@CellEditContext.CellValue?.ToString()" TextChanged="@OnEditValueChanged" ReadOnly="@Column.Readonly" Pattern="@ValidationPattern">
        <Feedback>
            @if ( ShowValidationFeedback )
            {
                <ValidationError />
            }
        </Feedback>
    </TextEdit>
}
